const dataToTree = (data, pid) => {
    const newData = []
    data && data.forEach((item) => {
        if (item.pid === pid) {
            item.children = dataToTree(data, item.id)
            newData.push(item)
        }
    })
    return newData;
}

module.exports = {
    dataToTree
}